﻿using UnityEngine;
using System.Collections;

public class Pipe : MonoBehaviour {

	// Use this for initialization
	void Start ()
	{
	    RandPositon();
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnTriggerExit(Collider other)
    {
        if (other.tag == "Player")
        {
            GameManage._intance.score++;
            AudioControl._intance.PlayAudio(AudioControl._intance.point);
        }
    }

    public void RandPositon()
    {
        float loc_y = Random.Range(-0.4f, -0.15f);
        this.transform.localPosition = new Vector3(this.transform.localPosition.x, loc_y, this.transform.localPosition.z);
    }

    void OnGUI()
    {
        GUILayout.Label("Score = " + GameManage._intance.score);
    }
}
